<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>[Generic Component Framework v3] GCF&#39;s GDriveLite component</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<!--link href="tabs.css" rel="stylesheet" type="text/css"-->
</head><body>
 <div id="wrapper">
    <div id="logo_box">
        <a class="img_link" href="https://github.com/pnudupa/gcf" target="_blank" ><img style="float:left;margin-left:10px;margin-top:5px;margin-bottom:5px;"src="header_gcf_logo.jpg" alt="GCF LOGO"/></a>
        <a class="img_link" href="https://www.vcreatelogic.com/" target="_blank" ><img style="float:right;margin-right:10px; margin-top: 30px;" src="header_vcl_logo.jpg" alt="VCL LOGO"/></a>
        <div style="clear:both"></div>
    </div>
    <div class="nav">
        <ul>
            <li class="selectedpage">
                <a class="a-home" href="index.html" >
                    <span>Home</span>
                </a>
            </li>
            <li>
                <a class="a-classes " href="classes.html">
                    <span>All Classes</span>
                </a>
            </li>
            <li>
                <a class="a-home " href="gcf_modules.html">
                    <span>Modules</span>
                </a>
            </li>
            <li>
                <a class="a-home " href="gcf_guides_and_videos.html">
                    <span>Guides & Videos</span>
                </a>
            </li>
            <li>
                <a class="a-home " href="gcf_tools_and_inbuilt_components.html">
                    <span>Tools & Components</span>
                </a>
            </li>
        </ul>
    </div>
    <div id="main-content">
        <div class="inside">
        <div>
<!-- Generated by Doxygen 1.8.16 -->
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a>  </div>
  <div class="headertitle">
<div class="title">GCF's GDriveLite component</div>  </div>
</div><!--header-->
<div class="contents">

<p> 
<div style="border: 1px solid black; padding: 20px; margin: 20px; font-size: 1.25em;">
GCF's GDriveLite is no longer guaranteed to work in 2019. The source code & documentation is
provided only if you want to use it as an inspiraton to build your own stack. We strongly recommend that
you use <a href="https://doc.qt.io/qt-5/qtnetworkauth-index.html" target="_blank">Qt Network Authorization</a> to enable Google Drive API access in your applications.
By default GCF's GDriveLite component and examples are not compiled along with GCF. You have to explicitly
enable compilation of these modules.
</div>
  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_g_drive_content_1_1_permission.html">GCF::GDriveContent::Permission</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_g_drive_content_1_1_user.html">GCF::GDriveContent::User</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_g_drive_content_1_1_properties.html">GCF::GDriveContent::Properties</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_g_drive_content_1_1_image_media_meta_data.html">GCF::GDriveContent::ImageMediaMetaData</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_g_drive_content_1_1_item_parent.html">GCF::GDriveContent::ItemParent</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_g_drive_content_1_1_item.html">GCF::GDriveContent::Item</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_g_drive_content_1_1_authenticated_user.html">GCF::GDriveContent::AuthenticatedUser</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_g_drive_content_1_1_child.html">GCF::GDriveContent::Child</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_i_g_drive_lite.html">GCF::IGDriveLite</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">This interface gives access to all GDriveLite component functionalities.  <a href="class_g_c_f_1_1_i_g_drive_lite.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_i_g_drive_lite_authenticator.html">GCF::IGDriveLiteAuthenticator</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">This is class helps the user to authenticate..  <a href="class_g_c_f_1_1_i_g_drive_lite_authenticator.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_i_g_drive_lite_content_model.html">GCF::IGDriveLiteContentModel</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">This interface provides access to the content-structure of Google Drive.  <a href="class_g_c_f_1_1_i_g_drive_lite_content_model.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_i_g_drive_lite_content_sharing_model.html">GCF::IGDriveLiteContentSharingModel</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">This interface provides access to permissions of a file/folder item.  <a href="class_g_c_f_1_1_i_g_drive_lite_content_sharing_model.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_i_g_drive_lite_file_downloader.html">GCF::IGDriveLiteFileDownloader</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">An interface to download a file from Google Drive.  <a href="class_g_c_f_1_1_i_g_drive_lite_file_downloader.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_i_g_drive_lite_file_downloader_list_model.html">GCF::IGDriveLiteFileDownloaderListModel</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Provides access to all downloaders from this component as a model.  <a href="class_g_c_f_1_1_i_g_drive_lite_file_downloader_list_model.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_i_g_drive_lite_file_uploader.html">GCF::IGDriveLiteFileUploader</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">An interface to upload a file into google-drive.  <a href="class_g_c_f_1_1_i_g_drive_lite_file_uploader.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_i_g_drive_lite_file_uploader_list_model.html">GCF::IGDriveLiteFileUploaderListModel</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Helper class for accessing details of file uploaders as model.  <a href="class_g_c_f_1_1_i_g_drive_lite_file_uploader_list_model.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>GDriveLite is an in-built component in GCF that makes it possible to bring Google Drive to your applications. With this component you can</p>
<ul>
<li>Authenticate a Google Account and access its Drive contents</li>
<li>Access the content-structure of the drive (through a model)</li>
<li>Upload / Download files</li>
<li>Share / Unshare files and folders in the drive</li>
<li>Star / Unstar files and folders in the drive</li>
<li>Trash / Untrash / Permanently Delete files and folders in the drive</li>
<li>Rename files and folders</li>
<li>Create directories</li>
<li>Move files and directories to other directories</li>
</ul>
<p>GCF comes bundled with two example programs: <a class="el" href="gcf_gdrivelitegui.html">GDriveLiteGui</a> and <a class="el" href="gcf_gdriveliteqml.html">GDriveLiteQml</a>. These programs showcase how the component can be used to build a full-fledged drive-aware application using widgets and QML.</p>
<h1><a class="anchor" id="gcf_gdrivelite_0"></a>
Registering your application with Google API Console</h1>
<p>To work with Google Drive API, you will need to register your application with Google using its API Console.</p>
<h2><a class="anchor" id="gcf_gdrivelite_01"></a>
Step 1: Visit Google API Console</h2>
<p>Open <a href="https://code.google.com/apis/console/">https://code.google.com/apis/console/</a> in your web-browser.</p>
<div class="image">
<img src="api-console.png" alt=""/>
</div>
<p>Click on the "Create Project" button and switch to the "Services" tab.</p>
<div class="image">
<img src="api-console1.png" alt=""/>
</div>
<p>From the list of services, switch on (or enable) Drive-API service access.</p>
<div class="image">
<img src="api-console2.png" alt=""/>
</div>
<p>In the API-Access tab, create an OAuth Client-ID.</p>
<div class="image">
<img src="api-console3.png" alt=""/>
</div>
<p> 
&nbsp;
</p>
<div class="image">
<img src="api-console4.png" alt=""/>
</div>
<p> 
&nbsp;
</p>
<div class="image">
<img src="api-console5.png" alt=""/>
</div>
<dl class="section note"><dt>Note</dt><dd>Make sure that you selected "Installed Application" as application-type; and "Other" as installed application type.</dd></dl>
<div class="image">
<img src="api-console6.png" alt=""/>
</div>
<p>Upon creation of Client-ID; you will notice a <code>client-id</code> and <code>client-secret</code> string in your API console. Make note of these strings, you will need to use them in your code for using the GDriveLite component.</p>
<h1><a class="anchor" id="gcf_gdrivelite_1"></a>
Loading GDriveLite component in your GCF applications</h1>
<p>Once you have the <code>client-id</code> and <code>client-secret</code>, you can load the GDriveLite component in your code as follows</p>
<div class="fragment"><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)</div>
<div class="line">{</div>
<div class="line">    <a class="code" href="class_g_c_f_1_1_gui_application.html">GCF::GuiApplication</a> a(argc, argv);</div>
<div class="line"> </div>
<div class="line">    QList&lt; QPair&lt;QByteArray,QVariant&gt; &gt; props;</div>
<div class="line">    props &lt;&lt; qMakePair&lt;QByteArray,QVariant&gt;(<span class="stringliteral">&quot;clientID&quot;</span>, <span class="stringliteral">&quot;78399023134.apps.googleusercontent.com&quot;</span>);</div>
<div class="line">    props &lt;&lt; qMakePair&lt;QByteArray,QVariant&gt;(<span class="stringliteral">&quot;clientSecret&quot;</span>, <span class="stringliteral">&quot;QiA5B6kXo0gNWcn-6UKpggsJ&quot;</span>);</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="class_g_c_f_1_1_component.html">GCF::Component</a> *gDriveLite = a.loadComponent(<span class="stringliteral">&quot;GDrive/GDriveLite&quot;</span>, props);</div>
<div class="line">    <span class="keywordflow">if</span>(!gDriveLite)</div>
<div class="line">        return ::error(<span class="stringliteral">&quot;Could not load GDrive/GDriveLite component&quot;</span>);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// ....</span></div>
<div class="line">}</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>To load GDriveLite component in your application, you must ensure that GCF's <code>Binary</code> folder is available in PATH / LD_LIBRARY_PATH / DYLD_LIBRARY_PATH.</dd></dl>
<h1><a class="anchor" id="gcf_gdrivelite_2"></a>
Authorising GDriveLite to access drive data</h1>
<p>The first thing you will need to do is to authorize GDriveLite to access your drive content. For this, you can make use of the <a class="el" href="class_g_c_f_1_1_i_g_drive_lite_authenticator.html">GCF::IGDriveLiteAuthenticator</a> interface. The following code-snippet shows you how to do that</p>
<div class="fragment"><div class="line"><a class="code" href="class_g_c_f_1_1_component.html">GCF::Component</a> *gDriveLite = a.loadComponent(<span class="stringliteral">&quot;GDrive/GDriveLite&quot;</span>, props);</div>
<div class="line"><span class="keywordflow">if</span>(!gDriveLite)</div>
<div class="line">    return ::error(<span class="stringliteral">&quot;Could not load GDrive/GDriveLite component&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Get the central interface of GDriveLite and then fetch the authenticator</span></div>
<div class="line"><span class="comment">// interface from it.</span></div>
<div class="line"><a class="code" href="class_g_c_f_1_1_i_g_drive_lite.html">GCF::IGDriveLite</a> *gDriveIface = qobject_cast&lt;GCF::IGDriveLite*&gt;(gDriveLite);</div>
<div class="line"><a class="code" href="class_g_c_f_1_1_i_g_drive_lite_authenticator.html">GCF::IGDriveLiteAuthenticator</a> *auth = gDriveIface-&gt;<a class="code" href="class_g_c_f_1_1_i_g_drive_lite.html#a5d59d7f32f0384bc7ceb4c724e6c7acc">authenticator</a>();</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Show the authentication URL in a web-view.</span></div>
<div class="line">QWebView webView;</div>
<div class="line">webView.setUrl( auth-&gt;<a class="code" href="class_g_c_f_1_1_i_g_drive_lite_authenticator.html#a3b13a7f54ae6377963143813f2987d46">authenticationPageUrl</a>() );</div>
<div class="line">webView.show();</div>
<div class="line"> </div>
<div class="line"><span class="comment">// username and password in the login-page. He will then be taken to</span></div>
<div class="line"><span class="comment">// a authorization page, where he should authorize access to your application.</span></div>
<div class="line"><span class="comment">// Upon success - a token is sent back via &#39;document title&#39; of the HTML</span></div>
<div class="line"><span class="comment">// page.</span></div>
<div class="line"> </div>
<div class="line"><a class="code" href="class_g_c_f_1_1_result.html">GCF::Result</a> result = auth-&gt;<a class="code" href="class_g_c_f_1_1_i_g_drive_lite_authenticator.html#a800aeb2ee1362869733e1ebeacf7fe65">authenticateFromPageTitle</a>( webView.title() );</div>
<div class="line"><span class="keywordflow">if</span>(result.<a class="code" href="class_g_c_f_1_1_result.html#ae026676b8d467f5db07d78e1499f7af1">isSuccess</a>())</div>
<div class="line">{</div>
<div class="line">    <span class="comment">// Authorization successful</span></div>
<div class="line">}</div>
<div class="line"><span class="keywordflow">else</span></div>
<div class="line">{</div>
<div class="line">    <span class="comment">// Show result.message() as error to user and abort</span></div>
<div class="line">}</div>
</div><!-- fragment --><dl class="section see"><dt>See also</dt><dd><a class="el" href="class_g_c_f_1_1_i_g_drive_lite.html">GCF::IGDriveLite</a> </dd>
<dd>
<a class="el" href="class_g_c_f_1_1_i_g_drive_lite_authenticator.html">GCF::IGDriveLiteAuthenticator</a> </dd>
<dd>
<a class="el" href="class_g_c_f_1_1_i_g_drive_lite_content_model.html">GCF::IGDriveLiteContentModel</a> </dd>
<dd>
<a class="el" href="class_g_c_f_1_1_i_g_drive_lite_content_sharing_model.html">GCF::IGDriveLiteContentSharingModel</a> </dd>
<dd>
<a class="el" href="class_g_c_f_1_1_i_g_drive_lite_file_downloader.html">GCF::IGDriveLiteFileDownloader</a> </dd>
<dd>
<a class="el" href="class_g_c_f_1_1_i_g_drive_lite_file_downloader_list_model.html">GCF::IGDriveLiteFileDownloaderListModel</a> </dd>
<dd>
<a class="el" href="class_g_c_f_1_1_i_g_drive_lite_file_uploader.html">GCF::IGDriveLiteFileUploader</a> </dd>
<dd>
<a class="el" href="class_g_c_f_1_1_i_g_drive_lite_file_uploader_list_model.html">GCF::IGDriveLiteFileUploaderListModel</a> </dd>
<dd>
<a class="el" href="gcf_gdrivelitegui.html">GDriveLiteGui - Example application for GCF's GDriveLite</a> </dd>
<dd>
<a class="el" href="gcf_gdriveliteqml.html">GDriveLiteQml - Example application for GCF's GDriveLite</a> </dd></dl>
</div><!-- contents -->
<div class="ttc" id="aclass_g_c_f_1_1_i_g_drive_lite_authenticator_html_a3b13a7f54ae6377963143813f2987d46"><div class="ttname"><a href="class_g_c_f_1_1_i_g_drive_lite_authenticator.html#a3b13a7f54ae6377963143813f2987d46">GCF::IGDriveLiteAuthenticator::authenticationPageUrl</a></div><div class="ttdeci">virtual QUrl authenticationPageUrl() const =0</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_component_html"><div class="ttname"><a href="class_g_c_f_1_1_component.html">GCF::Component</a></div><div class="ttdoc">Base class for all GCF components.</div><div class="ttdef"><b>Definition:</b> Component.h:52</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_gui_application_html"><div class="ttname"><a href="class_g_c_f_1_1_gui_application.html">GCF::GuiApplication</a></div><div class="ttdoc">Extends GCF::Application for GUI Applications.</div><div class="ttdef"><b>Definition:</b> GuiApplication.h:44</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_result_html"><div class="ttname"><a href="class_g_c_f_1_1_result.html">GCF::Result</a></div><div class="ttdoc">This class allows representation of the result of a process and/or function.</div><div class="ttdef"><b>Definition:</b> GCFGlobal.h:58</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_i_g_drive_lite_html_a5d59d7f32f0384bc7ceb4c724e6c7acc"><div class="ttname"><a href="class_g_c_f_1_1_i_g_drive_lite.html#a5d59d7f32f0384bc7ceb4c724e6c7acc">GCF::IGDriveLite::authenticator</a></div><div class="ttdeci">virtual GCF::IGDriveLiteAuthenticator * authenticator() const =0</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_i_g_drive_lite_authenticator_html_a800aeb2ee1362869733e1ebeacf7fe65"><div class="ttname"><a href="class_g_c_f_1_1_i_g_drive_lite_authenticator.html#a800aeb2ee1362869733e1ebeacf7fe65">GCF::IGDriveLiteAuthenticator::authenticateFromPageTitle</a></div><div class="ttdeci">virtual GCF::Result authenticateFromPageTitle(const QString &amp;title, QObject *notifyObject=0, const char *notifySlot=0)=0</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_i_g_drive_lite_authenticator_html"><div class="ttname"><a href="class_g_c_f_1_1_i_g_drive_lite_authenticator.html">GCF::IGDriveLiteAuthenticator</a></div><div class="ttdoc">This is class helps the user to authenticate..</div><div class="ttdef"><b>Definition:</b> IGDriveLiteAuthenticator.h:42</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_result_html_ae026676b8d467f5db07d78e1499f7af1"><div class="ttname"><a href="class_g_c_f_1_1_result.html#ae026676b8d467f5db07d78e1499f7af1">GCF::Result::isSuccess</a></div><div class="ttdeci">bool isSuccess() const</div><div class="ttdef"><b>Definition:</b> GCFGlobal.h:69</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_i_g_drive_lite_html"><div class="ttname"><a href="class_g_c_f_1_1_i_g_drive_lite.html">GCF::IGDriveLite</a></div><div class="ttdoc">This interface gives access to all GDriveLite component functionalities.</div><div class="ttdef"><b>Definition:</b> IGDriveLite.h:51</div></div>
</div>
</div>
</div>
<div class="footer_content">
<table width="100%" class="footer">
<tr>
<td align="left" width="50%">Copyright &copy; 2013-2019,
 <a class="el" href="http://www.vcreatelogic.com" target="_black">VCreate Logic Private Limited</a></td>
<td align="right" width="50%"><a class="el" href="http://www.vcreatelogic.com/products/gcf" target="_black">GCF - Generic Component Framework</a></td>
</tr>
</table>
</div>
</div>
</body>
</html>
